package kr.co.axxen.android.comutree;

import android.app.Activity;		
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.widget.ImageButton;

public class ComuTreeActivity extends Activity {
	private static WebView view = null;
	private ComuTreeAddress addr = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        startActivity(new Intent(this, ComuTreeLogoActivity.class));
        setContentView(R.layout.main);
        createWidget();
    }
    
    public final void onDestory() {
    	this.onDestory();
    	this.finish();
    }

	private final void createWidget() {
		addr = new ComuTreeAddress();
		view = (WebView) findViewById(R.id.contentView);
		view.setWebChromeClient(new WebChromeClient());
		view.loadUrl(addr.getMainURL());
		view.getSettings().setJavaScriptEnabled(true);
		
		ImageButton timeLineBtn = (ImageButton) findViewById(R.id.timeline);
		timeLineBtn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				view.loadUrl(addr.getTimelineURL());
			}
		});
		
		ImageButton communityBtn = (ImageButton) findViewById(R.id.community);
		communityBtn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				view.loadUrl(addr.getCommunityURL());
			}
		});
		
		ImageButton friendshipBtn = (ImageButton) findViewById(R.id.friendship);
		friendshipBtn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				view.loadUrl(addr.getFriendshipCafeURL());
			}
		});
		
		ImageButton messageFolderBtn = (ImageButton) findViewById(R.id.message);
		messageFolderBtn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				view.loadUrl(addr.getMessageFolderURL());
			}
		});
		
		ImageButton searchBtn = (ImageButton) findViewById(R.id.search);
		searchBtn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				view.loadUrl(addr.getSearchURL());
			}
		});
		
		ImageButton configureBtn =(ImageButton) findViewById(R.id.control);
		configureBtn.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				view.loadUrl(addr.getConfigureURL());
			}
		});

	}
}